// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]

/// Implements a client for the Cloud SQL Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_sql_v1::client::SqlBackupRunsService;
/// let client = SqlBackupRunsService::builder().build().await?;
/// // use `client` to make requests to the Cloud SQL Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for managing database backups.
///
/// # Configuration
///
/// To configure `SqlBackupRunsService` use the `with_*` methods in the type returned
/// by [builder()][SqlBackupRunsService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://sqladmin.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::sql_backup_runs_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::sql_backup_runs_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `SqlBackupRunsService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `SqlBackupRunsService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct SqlBackupRunsService {
    inner: std::sync::Arc<dyn super::stub::dynamic::SqlBackupRunsService>,
}

impl SqlBackupRunsService {
    /// Returns a builder for [SqlBackupRunsService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_sql_v1::client::SqlBackupRunsService;
    /// let client = SqlBackupRunsService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::sql_backup_runs_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::sql_backup_runs_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::SqlBackupRunsService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SqlBackupRunsService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlBackupRunsService> {
        super::transport::SqlBackupRunsService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlBackupRunsService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::SqlBackupRunsService::new)
    }

    /// Deletes the backup taken by a backup run.
    pub fn delete(&self) -> super::builder::sql_backup_runs_service::Delete {
        super::builder::sql_backup_runs_service::Delete::new(self.inner.clone())
    }

    /// Retrieves a resource containing information about a backup run.
    pub fn get(&self) -> super::builder::sql_backup_runs_service::Get {
        super::builder::sql_backup_runs_service::Get::new(self.inner.clone())
    }

    /// Creates a new backup run on demand.
    pub fn insert(&self) -> super::builder::sql_backup_runs_service::Insert {
        super::builder::sql_backup_runs_service::Insert::new(self.inner.clone())
    }

    /// Lists all backup runs associated with the project or a given instance
    /// and configuration in the reverse chronological order of the backup
    /// initiation time.
    pub fn list(&self) -> super::builder::sql_backup_runs_service::List {
        super::builder::sql_backup_runs_service::List::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud SQL Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_sql_v1::client::SqlConnectService;
/// let client = SqlConnectService::builder().build().await?;
/// // use `client` to make requests to the Cloud SQL Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Cloud SQL connect service.
///
/// # Configuration
///
/// To configure `SqlConnectService` use the `with_*` methods in the type returned
/// by [builder()][SqlConnectService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://sqladmin.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::sql_connect_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::sql_connect_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `SqlConnectService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `SqlConnectService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct SqlConnectService {
    inner: std::sync::Arc<dyn super::stub::dynamic::SqlConnectService>,
}

impl SqlConnectService {
    /// Returns a builder for [SqlConnectService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_sql_v1::client::SqlConnectService;
    /// let client = SqlConnectService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::sql_connect_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::sql_connect_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::SqlConnectService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SqlConnectService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlConnectService> {
        super::transport::SqlConnectService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlConnectService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::SqlConnectService::new)
    }

    /// Retrieves connect settings about a Cloud SQL instance.
    pub fn get_connect_settings(&self) -> super::builder::sql_connect_service::GetConnectSettings {
        super::builder::sql_connect_service::GetConnectSettings::new(self.inner.clone())
    }

    /// Generates a short-lived X509 certificate containing the provided public key
    /// and signed by a private key specific to the target instance. Users may use
    /// the certificate to authenticate as themselves when connecting to the
    /// database.
    pub fn generate_ephemeral_cert(
        &self,
    ) -> super::builder::sql_connect_service::GenerateEphemeralCert {
        super::builder::sql_connect_service::GenerateEphemeralCert::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud SQL Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_sql_v1::client::SqlDatabasesService;
/// let client = SqlDatabasesService::builder().build().await?;
/// // use `client` to make requests to the Cloud SQL Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service to manage databases.
///
/// # Configuration
///
/// To configure `SqlDatabasesService` use the `with_*` methods in the type returned
/// by [builder()][SqlDatabasesService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://sqladmin.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::sql_databases_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::sql_databases_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `SqlDatabasesService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `SqlDatabasesService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct SqlDatabasesService {
    inner: std::sync::Arc<dyn super::stub::dynamic::SqlDatabasesService>,
}

impl SqlDatabasesService {
    /// Returns a builder for [SqlDatabasesService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_sql_v1::client::SqlDatabasesService;
    /// let client = SqlDatabasesService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::sql_databases_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::sql_databases_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::SqlDatabasesService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SqlDatabasesService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlDatabasesService> {
        super::transport::SqlDatabasesService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlDatabasesService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::SqlDatabasesService::new)
    }

    /// Deletes a database from a Cloud SQL instance.
    pub fn delete(&self) -> super::builder::sql_databases_service::Delete {
        super::builder::sql_databases_service::Delete::new(self.inner.clone())
    }

    /// Retrieves a resource containing information about a database inside a Cloud
    /// SQL instance.
    pub fn get(&self) -> super::builder::sql_databases_service::Get {
        super::builder::sql_databases_service::Get::new(self.inner.clone())
    }

    /// Inserts a resource containing information about a database inside a Cloud
    /// SQL instance.
    ///
    /// **Note:** You can't modify the default character set and collation.
    pub fn insert(&self) -> super::builder::sql_databases_service::Insert {
        super::builder::sql_databases_service::Insert::new(self.inner.clone())
    }

    /// Lists databases in the specified Cloud SQL instance.
    pub fn list(&self) -> super::builder::sql_databases_service::List {
        super::builder::sql_databases_service::List::new(self.inner.clone())
    }

    /// Partially updates a resource containing information about a database inside
    /// a Cloud SQL instance. This method supports patch semantics.
    pub fn patch(&self) -> super::builder::sql_databases_service::Patch {
        super::builder::sql_databases_service::Patch::new(self.inner.clone())
    }

    /// Updates a resource containing information about a database inside a Cloud
    /// SQL instance.
    pub fn update(&self) -> super::builder::sql_databases_service::Update {
        super::builder::sql_databases_service::Update::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud SQL Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_sql_v1::client::SqlFlagsService;
/// let client = SqlFlagsService::builder().build().await?;
/// // use `client` to make requests to the Cloud SQL Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service to manage database flags for Cloud SQL instances.
///
/// # Configuration
///
/// To configure `SqlFlagsService` use the `with_*` methods in the type returned
/// by [builder()][SqlFlagsService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://sqladmin.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::sql_flags_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::sql_flags_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `SqlFlagsService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `SqlFlagsService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct SqlFlagsService {
    inner: std::sync::Arc<dyn super::stub::dynamic::SqlFlagsService>,
}

impl SqlFlagsService {
    /// Returns a builder for [SqlFlagsService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_sql_v1::client::SqlFlagsService;
    /// let client = SqlFlagsService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::sql_flags_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::sql_flags_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::SqlFlagsService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SqlFlagsService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlFlagsService> {
        super::transport::SqlFlagsService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlFlagsService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::SqlFlagsService::new)
    }

    /// Lists all available database flags for Cloud SQL instances.
    pub fn list(&self) -> super::builder::sql_flags_service::List {
        super::builder::sql_flags_service::List::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud SQL Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_sql_v1::client::SqlInstancesService;
/// let client = SqlInstancesService::builder().build().await?;
/// // use `client` to make requests to the Cloud SQL Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service to manage Cloud SQL instances.
///
/// # Configuration
///
/// To configure `SqlInstancesService` use the `with_*` methods in the type returned
/// by [builder()][SqlInstancesService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://sqladmin.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::sql_instances_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::sql_instances_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `SqlInstancesService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `SqlInstancesService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct SqlInstancesService {
    inner: std::sync::Arc<dyn super::stub::dynamic::SqlInstancesService>,
}

impl SqlInstancesService {
    /// Returns a builder for [SqlInstancesService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_sql_v1::client::SqlInstancesService;
    /// let client = SqlInstancesService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::sql_instances_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::sql_instances_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::SqlInstancesService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SqlInstancesService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlInstancesService> {
        super::transport::SqlInstancesService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlInstancesService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::SqlInstancesService::new)
    }

    /// Adds a new trusted Certificate Authority (CA) version for the specified
    /// instance. Required to prepare for a certificate rotation. If a CA version
    /// was previously added but never used in a certificate rotation, this
    /// operation replaces that version. There cannot be more than one CA version
    /// waiting to be rotated in. For instances that have enabled Certificate
    /// Authority Service (CAS) based server CA, please use AddServerCertificate to
    /// add a new server certificate.
    pub fn add_server_ca(&self) -> super::builder::sql_instances_service::AddServerCa {
        super::builder::sql_instances_service::AddServerCa::new(self.inner.clone())
    }

    /// Creates a Cloud SQL instance as a clone of the source instance. Using this
    /// operation might cause your instance to restart.
    #[allow(clippy::should_implement_trait)]
    pub fn clone(&self) -> super::builder::sql_instances_service::Clone {
        super::builder::sql_instances_service::Clone::new(self.inner.clone())
    }

    /// Deletes a Cloud SQL instance.
    pub fn delete(&self) -> super::builder::sql_instances_service::Delete {
        super::builder::sql_instances_service::Delete::new(self.inner.clone())
    }

    /// Demotes the stand-alone instance to be a Cloud SQL read replica for an
    /// external database server.
    pub fn demote_master(&self) -> super::builder::sql_instances_service::DemoteMaster {
        super::builder::sql_instances_service::DemoteMaster::new(self.inner.clone())
    }

    /// Demotes an existing standalone instance to be a Cloud SQL read replica
    /// for an external database server.
    pub fn demote(&self) -> super::builder::sql_instances_service::Demote {
        super::builder::sql_instances_service::Demote::new(self.inner.clone())
    }

    /// Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL
    /// dump or CSV file.
    pub fn export(&self) -> super::builder::sql_instances_service::Export {
        super::builder::sql_instances_service::Export::new(self.inner.clone())
    }

    /// Initiates a manual failover of a high availability (HA) primary instance
    /// to a standby instance, which becomes the primary instance. Users are
    /// then rerouted to the new primary. For more information, see the
    /// [Overview of high
    /// availability](https://cloud.google.com/sql/docs/mysql/high-availability)
    /// page in the Cloud SQL documentation.
    /// If using Legacy HA (MySQL only), this causes the instance to failover to
    /// its failover replica instance.
    pub fn failover(&self) -> super::builder::sql_instances_service::Failover {
        super::builder::sql_instances_service::Failover::new(self.inner.clone())
    }

    /// Reencrypt CMEK instance with latest key version.
    pub fn reencrypt(&self) -> super::builder::sql_instances_service::Reencrypt {
        super::builder::sql_instances_service::Reencrypt::new(self.inner.clone())
    }

    /// Retrieves a resource containing information about a Cloud SQL instance.
    pub fn get(&self) -> super::builder::sql_instances_service::Get {
        super::builder::sql_instances_service::Get::new(self.inner.clone())
    }

    /// Imports data into a Cloud SQL instance from a SQL dump  or CSV file in
    /// Cloud Storage.
    pub fn import(&self) -> super::builder::sql_instances_service::Import {
        super::builder::sql_instances_service::Import::new(self.inner.clone())
    }

    /// Creates a new Cloud SQL instance.
    pub fn insert(&self) -> super::builder::sql_instances_service::Insert {
        super::builder::sql_instances_service::Insert::new(self.inner.clone())
    }

    /// Lists instances under a given project.
    pub fn list(&self) -> super::builder::sql_instances_service::List {
        super::builder::sql_instances_service::List::new(self.inner.clone())
    }

    /// Lists all of the trusted Certificate Authorities (CAs) for the specified
    /// instance. There can be up to three CAs listed: the CA that was used to sign
    /// the certificate that is currently in use, a CA that has been added but not
    /// yet used to sign a certificate, and a CA used to sign a certificate that
    /// has previously rotated out.
    pub fn list_server_cas(&self) -> super::builder::sql_instances_service::ListServerCas {
        super::builder::sql_instances_service::ListServerCas::new(self.inner.clone())
    }

    /// Partially updates settings of a Cloud SQL instance by merging the request
    /// with the current configuration. This method supports patch semantics.
    pub fn patch(&self) -> super::builder::sql_instances_service::Patch {
        super::builder::sql_instances_service::Patch::new(self.inner.clone())
    }

    /// Promotes the read replica instance to be an independent Cloud SQL
    /// primary instance.
    /// Using this operation might cause your instance to restart.
    pub fn promote_replica(&self) -> super::builder::sql_instances_service::PromoteReplica {
        super::builder::sql_instances_service::PromoteReplica::new(self.inner.clone())
    }

    /// Switches over from the primary instance to the designated DR replica
    /// instance.
    pub fn switchover(&self) -> super::builder::sql_instances_service::Switchover {
        super::builder::sql_instances_service::Switchover::new(self.inner.clone())
    }

    /// Deletes all client certificates and generates a new server SSL certificate
    /// for the instance.
    pub fn reset_ssl_config(&self) -> super::builder::sql_instances_service::ResetSslConfig {
        super::builder::sql_instances_service::ResetSslConfig::new(self.inner.clone())
    }

    /// Restarts a Cloud SQL instance.
    pub fn restart(&self) -> super::builder::sql_instances_service::Restart {
        super::builder::sql_instances_service::Restart::new(self.inner.clone())
    }

    /// Restores a backup of a Cloud SQL instance. Using this operation might cause
    /// your instance to restart.
    pub fn restore_backup(&self) -> super::builder::sql_instances_service::RestoreBackup {
        super::builder::sql_instances_service::RestoreBackup::new(self.inner.clone())
    }

    /// Rotates the server certificate to one signed by the Certificate Authority
    /// (CA) version previously added with the addServerCA method. For instances
    /// that have enabled Certificate Authority Service (CAS) based server CA,
    /// please use RotateServerCertificate to rotate the server certificate.
    pub fn rotate_server_ca(&self) -> super::builder::sql_instances_service::RotateServerCa {
        super::builder::sql_instances_service::RotateServerCa::new(self.inner.clone())
    }

    /// Starts the replication in the read replica instance.
    pub fn start_replica(&self) -> super::builder::sql_instances_service::StartReplica {
        super::builder::sql_instances_service::StartReplica::new(self.inner.clone())
    }

    /// Stops the replication in the read replica instance.
    pub fn stop_replica(&self) -> super::builder::sql_instances_service::StopReplica {
        super::builder::sql_instances_service::StopReplica::new(self.inner.clone())
    }

    /// Truncate MySQL general and slow query log tables
    /// MySQL only.
    pub fn truncate_log(&self) -> super::builder::sql_instances_service::TruncateLog {
        super::builder::sql_instances_service::TruncateLog::new(self.inner.clone())
    }

    /// Updates settings of a Cloud SQL instance. Using this operation might cause
    /// your instance to restart.
    pub fn update(&self) -> super::builder::sql_instances_service::Update {
        super::builder::sql_instances_service::Update::new(self.inner.clone())
    }

    /// Generates a short-lived X509 certificate containing the provided public key
    /// and signed by a private key specific to the target instance. Users may use
    /// the certificate to authenticate as themselves when connecting to the
    /// database.
    pub fn create_ephemeral(&self) -> super::builder::sql_instances_service::CreateEphemeral {
        super::builder::sql_instances_service::CreateEphemeral::new(self.inner.clone())
    }

    /// Reschedules the maintenance on the given instance.
    pub fn reschedule_maintenance(
        &self,
    ) -> super::builder::sql_instances_service::RescheduleMaintenance {
        super::builder::sql_instances_service::RescheduleMaintenance::new(self.inner.clone())
    }

    /// Verify External primary instance external sync settings.
    pub fn verify_external_sync_settings(
        &self,
    ) -> super::builder::sql_instances_service::VerifyExternalSyncSettings {
        super::builder::sql_instances_service::VerifyExternalSyncSettings::new(self.inner.clone())
    }

    /// Start External primary instance migration.
    pub fn start_external_sync(&self) -> super::builder::sql_instances_service::StartExternalSync {
        super::builder::sql_instances_service::StartExternalSync::new(self.inner.clone())
    }

    /// Perform Disk Shrink on primary instance.
    pub fn perform_disk_shrink(&self) -> super::builder::sql_instances_service::PerformDiskShrink {
        super::builder::sql_instances_service::PerformDiskShrink::new(self.inner.clone())
    }

    /// Get Disk Shrink Config for a given instance.
    pub fn get_disk_shrink_config(
        &self,
    ) -> super::builder::sql_instances_service::GetDiskShrinkConfig {
        super::builder::sql_instances_service::GetDiskShrinkConfig::new(self.inner.clone())
    }

    /// Reset Replica Size to primary instance disk size.
    pub fn reset_replica_size(&self) -> super::builder::sql_instances_service::ResetReplicaSize {
        super::builder::sql_instances_service::ResetReplicaSize::new(self.inner.clone())
    }

    /// Get Latest Recovery Time for a given instance.
    pub fn get_latest_recovery_time(
        &self,
    ) -> super::builder::sql_instances_service::GetLatestRecoveryTime {
        super::builder::sql_instances_service::GetLatestRecoveryTime::new(self.inner.clone())
    }

    /// Acquire a lease for the setup of SQL Server Reporting Services (SSRS).
    pub fn acquire_ssrs_lease(&self) -> super::builder::sql_instances_service::AcquireSsrsLease {
        super::builder::sql_instances_service::AcquireSsrsLease::new(self.inner.clone())
    }

    /// Release a lease for the setup of SQL Server Reporting Services (SSRS).
    pub fn release_ssrs_lease(&self) -> super::builder::sql_instances_service::ReleaseSsrsLease {
        super::builder::sql_instances_service::ReleaseSsrsLease::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud SQL Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_sql_v1::client::SqlOperationsService;
/// let client = SqlOperationsService::builder().build().await?;
/// // use `client` to make requests to the Cloud SQL Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service to fetch operations for database instances.
///
/// # Configuration
///
/// To configure `SqlOperationsService` use the `with_*` methods in the type returned
/// by [builder()][SqlOperationsService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://sqladmin.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::sql_operations_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::sql_operations_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `SqlOperationsService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `SqlOperationsService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct SqlOperationsService {
    inner: std::sync::Arc<dyn super::stub::dynamic::SqlOperationsService>,
}

impl SqlOperationsService {
    /// Returns a builder for [SqlOperationsService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_sql_v1::client::SqlOperationsService;
    /// let client = SqlOperationsService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::sql_operations_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::sql_operations_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::SqlOperationsService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SqlOperationsService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlOperationsService> {
        super::transport::SqlOperationsService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlOperationsService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::SqlOperationsService::new)
    }

    /// Retrieves an instance operation that has been performed on an instance.
    pub fn get(&self) -> super::builder::sql_operations_service::Get {
        super::builder::sql_operations_service::Get::new(self.inner.clone())
    }

    /// Lists all instance operations that have been performed on the given Cloud
    /// SQL instance in the reverse chronological order of the start time.
    pub fn list(&self) -> super::builder::sql_operations_service::List {
        super::builder::sql_operations_service::List::new(self.inner.clone())
    }

    /// Cancels an instance operation that has been performed on an instance.
    pub fn cancel(&self) -> super::builder::sql_operations_service::Cancel {
        super::builder::sql_operations_service::Cancel::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud SQL Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_sql_v1::client::SqlSslCertsService;
/// let client = SqlSslCertsService::builder().build().await?;
/// // use `client` to make requests to the Cloud SQL Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service to manage SSL certs for Cloud SQL instances.
///
/// # Configuration
///
/// To configure `SqlSslCertsService` use the `with_*` methods in the type returned
/// by [builder()][SqlSslCertsService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://sqladmin.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::sql_ssl_certs_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::sql_ssl_certs_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `SqlSslCertsService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `SqlSslCertsService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct SqlSslCertsService {
    inner: std::sync::Arc<dyn super::stub::dynamic::SqlSslCertsService>,
}

impl SqlSslCertsService {
    /// Returns a builder for [SqlSslCertsService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_sql_v1::client::SqlSslCertsService;
    /// let client = SqlSslCertsService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::sql_ssl_certs_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::sql_ssl_certs_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::SqlSslCertsService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SqlSslCertsService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlSslCertsService> {
        super::transport::SqlSslCertsService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlSslCertsService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::SqlSslCertsService::new)
    }

    /// Deletes the SSL certificate. For First Generation instances, the
    /// certificate remains valid until the instance is restarted.
    pub fn delete(&self) -> super::builder::sql_ssl_certs_service::Delete {
        super::builder::sql_ssl_certs_service::Delete::new(self.inner.clone())
    }

    /// Retrieves a particular SSL certificate.  Does not include the private key
    /// (required for usage).  The private key must be saved from the response to
    /// initial creation.
    pub fn get(&self) -> super::builder::sql_ssl_certs_service::Get {
        super::builder::sql_ssl_certs_service::Get::new(self.inner.clone())
    }

    /// Creates an SSL certificate and returns it along with the private key and
    /// server certificate authority.  The new certificate will not be usable until
    /// the instance is restarted.
    pub fn insert(&self) -> super::builder::sql_ssl_certs_service::Insert {
        super::builder::sql_ssl_certs_service::Insert::new(self.inner.clone())
    }

    /// Lists all of the current SSL certificates for the instance.
    pub fn list(&self) -> super::builder::sql_ssl_certs_service::List {
        super::builder::sql_ssl_certs_service::List::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud SQL Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_sql_v1::client::SqlTiersService;
/// let client = SqlTiersService::builder().build().await?;
/// // use `client` to make requests to the Cloud SQL Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for providing machine types (tiers) for Cloud SQL instances.
///
/// # Configuration
///
/// To configure `SqlTiersService` use the `with_*` methods in the type returned
/// by [builder()][SqlTiersService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://sqladmin.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::sql_tiers_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::sql_tiers_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `SqlTiersService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `SqlTiersService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct SqlTiersService {
    inner: std::sync::Arc<dyn super::stub::dynamic::SqlTiersService>,
}

impl SqlTiersService {
    /// Returns a builder for [SqlTiersService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_sql_v1::client::SqlTiersService;
    /// let client = SqlTiersService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::sql_tiers_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::sql_tiers_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::SqlTiersService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SqlTiersService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlTiersService> {
        super::transport::SqlTiersService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlTiersService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::SqlTiersService::new)
    }

    /// Lists all available machine types (tiers) for Cloud SQL, for example,
    /// `db-custom-1-3840`. For more information, see
    /// <https://cloud.google.com/sql/pricing>.
    pub fn list(&self) -> super::builder::sql_tiers_service::List {
        super::builder::sql_tiers_service::List::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud SQL Admin API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_sql_v1::client::SqlUsersService;
/// let client = SqlUsersService::builder().build().await?;
/// // use `client` to make requests to the Cloud SQL Admin API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Cloud SQL users service.
///
/// # Configuration
///
/// To configure `SqlUsersService` use the `with_*` methods in the type returned
/// by [builder()][SqlUsersService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://sqladmin.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::sql_users_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::sql_users_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `SqlUsersService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `SqlUsersService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct SqlUsersService {
    inner: std::sync::Arc<dyn super::stub::dynamic::SqlUsersService>,
}

impl SqlUsersService {
    /// Returns a builder for [SqlUsersService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_sql_v1::client::SqlUsersService;
    /// let client = SqlUsersService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::sql_users_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::sql_users_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::SqlUsersService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SqlUsersService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlUsersService> {
        super::transport::SqlUsersService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SqlUsersService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::SqlUsersService::new)
    }

    /// Deletes a user from a Cloud SQL instance.
    pub fn delete(&self) -> super::builder::sql_users_service::Delete {
        super::builder::sql_users_service::Delete::new(self.inner.clone())
    }

    /// Retrieves a resource containing information about a user.
    pub fn get(&self) -> super::builder::sql_users_service::Get {
        super::builder::sql_users_service::Get::new(self.inner.clone())
    }

    /// Creates a new user in a Cloud SQL instance.
    pub fn insert(&self) -> super::builder::sql_users_service::Insert {
        super::builder::sql_users_service::Insert::new(self.inner.clone())
    }

    /// Lists users in the specified Cloud SQL instance.
    pub fn list(&self) -> super::builder::sql_users_service::List {
        super::builder::sql_users_service::List::new(self.inner.clone())
    }

    /// Updates an existing user in a Cloud SQL instance.
    pub fn update(&self) -> super::builder::sql_users_service::Update {
        super::builder::sql_users_service::Update::new(self.inner.clone())
    }
}
